#!/bin/bash

set -o errexit
set -o nounset

tin() {
  _tmp/deps/tin.tin "$@"
}

Build() {
  PYTHONPATH=.:$CDI_DEPS tin build-python fly --out $CDI_OUT/fly.tin

  poly build doc/
}

Test() {
   # TODO: fix tests
   exit 0
  ./do.sh unit ./fly_test.py
}

# TODO: Are we going to use this zip?  It just contains the README and .tin
# file.  I think --help just can have a pointer to the home page of each tool,
# and we don't need a README.

make-release-zip() {
  local version=0.1
  $0 build
  cp fly.tin release
  pushd release
  local out=fly-$version.zip
  rm $out
  zip $out fly.tin README
  popd
}

Deploy() {
  scp $CDI_OUT/fly.tin $PBI_DEPLOY_DEST/fly/latest/

  # Deploy the Poly app.
  poly stage \
    --remote-root=/keg/deploy \
    --http-nodes=http://localhost:8050 \
    doc/
}

"$@"
